package com.sa07.ui.components;

import java.awt.Color;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JButton;

import com.sa07.ui.enums.TestResult;

/**
 * 状态栏控件
 * 
 * @author Long.shangbo
 *
 * 2014-2-16 下午2:25:38
 */
public class JstatusControl extends JButton {

	private static final long serialVersionUID = -4223422946467428966L;
	
	public JstatusControl(String label){
		super(label);
		setBorder(BorderFactory.createEtchedBorder());
		setFont(new Font(null, Font.BOLD, 14));
	}
	
	/**
	 * 禁用
	 */
	public void disabled(){
		setEnabled(false);
		setBackground(Color.WHITE);
		setForeground(Color.WHITE);
	}

	/**
	 * 设置测试结果<br>
	 * 根据测试结果来对控件进行相应的背景颜色、字体、事件进行处理
	 * @param color
	 */
	public void setTestResult(TestResult result) {
		switch (result) {
			case SUCCESS:
				setBackground(Color.GREEN);
				setForeground(Color.BLACK);
				break;
			case FAILED:
				setBackground(Color.RED);
				setForeground(Color.WHITE);
				break;
			case PROCESS:
				setBackground(Color.yellow);
				setForeground(Color.WHITE);
				break;	
			default:
				setBackground(Color.RED);
				setForeground(Color.WHITE);
				break;
		}
	}
}
